package enemy;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import bullets.BulletEnemy;
import core.Boom;
import core.World;

public class Bee extends Enemy implements Reward,Score{
	/**
	 * 
	 */
	private static final long serialVersionUID = 4797481432285002705L;
	private static BufferedImage[] image = new BufferedImage[1];
	static {
		image[0] = readImage("src/images/bee.png");	
	}
	private int xSpeed;
	private int ySpeed;
	private int reward=(int)(Math.random()*20);
	private int score=1;
	
	public Bee() {
		super();
	}

	public Bee(int beeSpeed) {
		super(103, 77);	
		xSpeed=beeSpeed;
		ySpeed=beeSpeed;
	}

	@Override
	public void step() {
		int flag = -1;
		if(x<0||x>(World.WORLD_WIDTH-this.width)) {
			xSpeed *=flag;
		}
			x +=xSpeed;
			y +=ySpeed;
	}
	public void step2(int x,int y) {//大招出现时的移动方式
		if(x<this.x) {
			this.x-=xSpeed;
		}else {
			this.x+=xSpeed;
		}
		if(y<this.y) {
			this.y-=ySpeed;
		}else {
			this.y+=ySpeed;
		}		
	}
	public void paintImage(Graphics g) {		
		if(status==live) {
			g.drawImage(image[0], x, y,null);
		}
		if(status==dead) {
			g.drawImage(Boom.image[index-1], x, y,null);
		}		
	}
	@Override
	public int getRewaqrdType() {
		if(reward<15) {		
			return ADD_DOUBLEFIRE;
		}
		return ADD_LIFE;
	}
	public int getSpeed() {
		return xSpeed;
	}
	public void setSpeed(int beeSpeed) {
		xSpeed=beeSpeed;
		ySpeed=beeSpeed;
	}
	
	public int getReward() {
		return reward;
	}

	public void setReward(int reward) {
		this.reward = reward;
	}

	public String toString() {
		return "Bee [x=" + x + ", y=" + y + ", status=" + status + "]";
	}

	@Override
	public BulletEnemy enemyShoot() {
		BulletEnemy be = new BulletEnemy(this.x+this.width/2,this.y+this.height);
		return be;
	}
	public int getScore() {
		return score;
	}
}
